<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="applicable-device" content="pc">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="icon" href="/icon.png" />
    <link rel="stylesheet" href="/static/index/css/reset.css">
    <link rel="stylesheet" href="/static/index/lib/bootstrap.css" />
    <link rel="stylesheet" href="/static/index/css/common.css" />
    <link rel="stylesheet" href="/static/index/css/home.css" />
    <link rel="stylesheet" href="/static/index/css/users.css" />
    <script src="/static/index/lib/jquery-2.1.4.js"></script>
    <script src="/static/index/lib/bootstrap.min.js"></script>
    <script type="text/javascript" src="/static/index/lib/template.js"></script>
    <script>
            var _hmt = _hmt || [];
            (function() {
              var hm = document.createElement("script");
              hm.src = "https://hm.baidu.com/hm.js?8b340ebdd740974de9d621b14ab09b43";
              var s = document.getElementsByTagName("script")[0]; 
              s.parentNode.insertBefore(hm, s);
            })();
        </script>
</head>

<body>
    {include file="public/push"}
    {include file="public/usersHeader"}
    <div class="widthFullScreen">
        <div class="wdSafe user_body clearfix">
            {include file="public/usersLeftNav"}
            <!-- left over -->
            <div class="pull-right right_wrap">
                <div class="nav_common border-top">
                    <ol class="breadcrumb pull-left">
                        <li><a href="/users/index">用户中心</a></li>
                        <li><a href="/users/index">我的资料</a></li>
                        <li class="active">经营团队</li>
                    </ol>
                    <a href="/users/companyTeamAdd" class="pull-right colorRed" style="line-height: 50px;">+添加成员</a>
                </div>
                <div class="comUser_wrap">
                    <div id="inforHtml"></div>
                    <script id="inforScript" type="text/html">
                        
                        <div class="row" style="margin: 0;">
                            {{each data item i}} 
                                <div class="col-md-3 anli_wrap">
                                    <img class="anliPic" src="{{item.avatar}}" alt="" />
                                    <ul class="anli_list_audit" dId="{{item.id}}">
                                        <li>
                                            <a href="/users/companyTeamEdit/{{item.id}}">编辑</a>
                                        </li>
                                        <li>
                                            <a href="javascript:;" onclick="deletTeam(this)">删除</a>
                                        </li>
                                        <li>
                                            <a href="javascript:;">{{item.isHid}}</a>
                                        </li>
                                    </ul>
                                </div>
                            {{/each}}  
                        </div>
                        
                    </script>

                </div>
            </div>
            <!-- right over -->
        </div>
    </div>
    <div class="widthFullScreen heightGray"></div>
    {include file="public/footer"}
    <!-- dailog -->
    <div class="modal fade modleDailog" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
        <div class="modal-dialog modal-sm" role="document" style="width: 400px;">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">提示</h4>
                </div>
                <div class="modal-body">
                    <input type="hidden" name="dateId" id="dateId" value="" />
                    <p class="dailog_word">是否确定要消耗一个订单券查看该笔订单？</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary">确认</button>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript" src="/static/index/layer/layer.js"></script>
    <script type="text/javascript">
    var baseUrl = 'https://api.qikuai100.com/',
        uid = localStorage.getItem("uid");

    $(function() {
        $('.modleDailog').modal("hide");
        initDate();
    });

    function values(ID) {
        $('#dateId').val(ID);
    }

    /**
     * 初始化数据
     */
    function initDate() {
        $.ajax({
            type: "POST",
            url: baseUrl + "api/staff/list",
            data: {
                uid: uid
            },
            success: function(result) {
                if (result.ret == 0) {
                    console.log(result)
                    if(result.data.length == 0 || !result.data.length){
                        layer.msg("您还没有添加成员，快去添加吧！");
                    }else{
                        for(var i =0;i <result.data.length; i++){
                            if(result.data[i].is_hidden == 1){
                                result.data[i].isHid = "显示";
                            }else{
                                result.data[i].isHid = "隐藏";
                            }
                        }
                    }
                    var inforHtml = template('inforScript', result);
                    document.getElementById('inforHtml').innerHTML = inforHtml;

                } else {
                    layer.msg(result.res_info);
                }
            }
        });
    };

    /**
     * 删除团队
     */
    function deletTeam(obj){
        var id = $(obj).parents("ul").attr("dId");
        layer.open({
            title: '删除'
            ,content: '您确定要删除此成员信息吗?删除后不可恢复。',
            yes: function(index, layero){
                $.ajax({
                    type: "POST",
                    url: baseUrl + "api/staff/del",
                    data: {
                        id: id
                    },
                    success: function(result) {
                        if (result.ret == 0) {
                            layer.msg("删除成功！");
                            initDate();
                        } else {
                            layer.msg(result.res_info);
                        }
                    }
                });
                layer.close(index);
            }
        }); 
        
    }
    </script>
</body>

</html>